﻿using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MobileControlGuru.Src
{
    public class DeviceCtrlJobListener : IJobListener
    {
        public string Name => "DeviceCtrlJobListener";

        public Task JobExecutionVetoed(IJobExecutionContext context, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

        public Task JobToBeExecuted(IJobExecutionContext context, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

       

        public Task JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException, CancellationToken cancellationToken = default)
        {
            // 检查作业是否成功执行
            if (jobException == null)
            {
                // 执行清理工作
                PerformCleanup(context);
            }
            // 如果有异常，可以根据需要处理
            return Task.CompletedTask;
        }

        private void PerformCleanup(IJobExecutionContext context)
        {
            // 清理逻辑...
            Tools.LogHelper.Info("清理逻辑..."+ context.JobDetail.Key.ToString());
            Console.WriteLine("清理逻辑..." + context.JobDetail.Key.ToString());
        }

        // 实现其他 IJobListener 接口方法...
    }
}
